﻿Public Class Rprofesion

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Eprofesion)
        Dim profesions As List(Of Eprofesion) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                profesions = DProfesion.SeleccionarTodo(descEmpresa)
                If profesions Is Nothing Then profesions = New List(Of Eprofesion)
                If DisplaySelect Then profesions.Insert(0, New Eprofesion("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return profesions
    End Function
    Public Shared Function SeleccionarXEstado(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Eprofesion)
        Dim profesions As List(Of Eprofesion) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                profesions = DProfesion.SeleccionarXEstado(descEmpresa)
                If profesions Is Nothing Then profesions = New List(Of Eprofesion)
                If DisplaySelect Then profesions.Insert(0, New Eprofesion("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return profesions
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pProfesion As Eprofesion) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DProfesion.Añadir(descEmpresa, pProfesion)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pProfesion As Eprofesion) As Boolean
        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                DProfesion.Editar(descEmpresa, pProfesion)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pProfesion As Eprofesion) As Boolean
        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                DProfesion.Eliminar(descEmpresa, pProfesion)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
    End Function

End Class
